package com.ss.android.article.browser.download.internal;

import android.text.TextUtils;
import android.webkit.URLUtil;
import java.io.File;

public final class DownloadTask {
    public String url;
    public String fileName;
    public String title;
    String thumbnail;
    public String fileDir;
    public long finishedSize;
    public long totalSize;
    public volatile DownloadState downloadState;
    public long createTime;

    public DownloadTask(String url, String saveDir, String tileName, String title, String thumbnail) {
        if(!URLUtil.isNetworkUrl(url)) {
            throw new IllegalArgumentException("invalid url,nust start with http://");
        }

        if(TextUtils.isEmpty(tileName)) {
            throw new IllegalArgumentException("invalid fileName");
        }

        this.url = url;
        this.fileName = tileName;
        this.title = title;
        this.thumbnail = thumbnail;
        this.fileDir = saveDir;
    }

    public final String getFilePath() {
        String v0 = this.fileDir;
        if(!v0.endsWith(File.separator)) {
            v0 = v0 + File.separator;
        }

        return v0 + this.fileName;
    }

    public final boolean equals(Object arg5) {
        boolean v0 = true;
        if(this != (((DownloadTask)arg5))) {
            if(arg5 == null) {
                v0 = false;
            }
            else if(this.getClass() != arg5.getClass()) {
                v0 = false;
            }
            else {
                if(this.fileName == null) {
                    if(((DownloadTask)arg5).fileName != null) {
                        return false;
                    }
                }
                else if(!this.fileName.equals(((DownloadTask)arg5).fileName)) {
                    return false;
                }

                if(this.fileDir == null) {
                    if(((DownloadTask)arg5).fileDir != null) {
                        return false;
                    }
                }
                else if(!this.fileDir.equals(((DownloadTask)arg5).fileDir)) {
                    return false;
                }

                if(this.url == null) {
                    if(((DownloadTask)arg5).url == null) {
                        return v0;
                    }

                    return false;
                }

                if(this.url.equals(((DownloadTask)arg5).url)) {
                    return v0;
                }

                v0 = false;
            }
        }

        return v0;
    }

    public final int hashCode() {
        int v1 = 0;
        int v0 = this.fileName == null ? 0 : this.fileName.hashCode();
        int v2 = (v0 + 31) * 31;
        v0 = this.fileDir == null ? 0 : this.fileDir.hashCode();
        v0 = (v0 + v2) * 31;
        if(this.url != null) {
            v1 = this.url.hashCode();
        }

        return v0 + v1;
    }

    public final String toString() {
        return "DownloadTask [url=" + this.url
                + ", finishedSize=" + this.finishedSize
                + ", totalSize=" + this.totalSize
                + ", dlPercent=0, downloadState=" + this.downloadState
                + ", fileName=" + this.fileName
                + ", title=" + this.title + "]";
    }
}

